package com.companion.companion.controller;

import java.util.List;

import com.companion.companion.domain.Caregiver;
import com.companion.companion.service.ICaregiverService;
import com.companion.companion.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 护工信息Controller
 * 
 * @author zly
 * @date 2025-05-06
 */@CrossOrigin
@RestController
@RequestMapping("/system/caregiver")
public class CaregiverController
{
    @Autowired
    private ICaregiverService caregiverService;

    /**
     * 查询护工信息列表
     */
    @GetMapping("/list")
    public List<Caregiver> list(Caregiver caregiver)
    {
        System.out.println(caregiver);
        // 前端未统一适配Result
        // return Result.success(caregiverService.selectCaregiverList(caregiver));
        return caregiverService.selectCaregiverList(caregiver);
    }


    /**
     * 获取护工信息详细信息
     */
    @GetMapping(value = "/{caregiverId}")
    public Caregiver getInfo(@PathVariable("caregiverId") Long caregiverId)
    {
        return caregiverService.selectCaregiverByCaregiverId(caregiverId);
    }

    /**
     * 新增护工信息
     */
    @PostMapping
    public int add(@RequestBody Caregiver caregiver)
    {
        return caregiverService.insertCaregiver(caregiver);
    }

    /**
     * 修改护工信息
     */
    @PutMapping
    public int edit(@RequestBody Caregiver caregiver)
    {
        return caregiverService.updateCaregiver(caregiver);
    }

    /**
     * 删除护工信息
     */
	@DeleteMapping("/{caregiverIds}")
    public int remove(@PathVariable Long[] caregiverIds)
    {
        return caregiverService.deleteCaregiverByCaregiverIds(caregiverIds);
    }
}
